<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />



</head>


<body>

	<body>
    <ul class="forminfo forminfo_mobile" style="margin-top: 20px;">
  		
    	<li><label>提问人</label><div class="label_right  label_right_mobile">${question.studentName }</div></li>
    	<li><label>	提问时间</label><div class="label_right  label_right_mobile">${question.sendTime }</div></li>
    	<li><label>问题</label><div class="label_right  label_right_mobile">${question.question }</div></li>
    	<c:if test="${userRole <6 }">
    	 <li class="tittle_li"> 我来回复</li>
    	 <li><textarea class="long_text long_text2 long_text3 " name="ReplyContent" id="ReplyContent" rows="" cols="" maxlength="100"/></textarea></li>
    	<li><input name="" type="button" class="btn" onclick="submitForm()" value="回复"></li>
    	</c:if>
    	 <li class="tittle_li"> ${ questionReplyCount }条回复</li>
    	 <div id="reply">
    	   <c:forEach items="${questionReplyList}" var="questionReply"  varStatus="status">
    	 	<div class="hf">
				    	<li><label>回复人</label><div class="label_right">${questionReply.teacherName }</div></li>
				    	<li><label>	回复时间</label><div class="label_right">${questionReply.replyTime }</div></li>
				    	<li><label>	回复内容</label><div class="label_right">${questionReply.replyContent }</div></li>
				    	<div class="clearfix"></div>
     		 </div>
     	 </c:forEach>
      </div>
    </ul> 
    <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="js/jquery.tips.js"></script>
     <script src="layer/layer.js"></script>
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	QuestionId ='${question.id}'
	 function submitForm() {
			if ($("textarea[name='ReplyContent']").val() == "") {
				showTips($("textarea[name='ReplyContent']"), '请填写回复内容!');
				return false;
			}
			$.ajax({
				type : "POST",
				url : "question/add_reply.do",
				data : {
						QuestionId:QuestionId,
						ReplyContent : $("textarea[name='ReplyContent']").val()
				},
				async : true,
				dataType : "json",
				success : function(data) {
					if ("error" == data.questionReplyList) {
						layer.alert('回复失败!', {
							skin : 'layer-ext-moon'
						});
					} else {
						$("#reply").empty();
						for(var i in data.questionReplyList){ 
							 var $str =" <div class='hf'>"
						    	+"<li><label>回复人</label><div class='label_right'>"+data.questionReplyList[i].teacherName+"</div></li>"
								+"<li><label>	回复时间</label><div class='label_right'>"+data.questionReplyList[i].replyTime+"</div></li>"
						    	+"<li><label>	回复内容</label><div class='label_right'>"+data.questionReplyList[i].replyContent+"</div></li>"
						    	+"<div class='clearfix'></div>"
		    					+"</div>";
		    					$("#reply").append($str);
						}
						$("#ReplyContent").val(''); 
					}
					
				}
			})
	 }
	function showTips(obj,tips) {
		obj.tips({
			side:3,
	        msg:tips,
	        bg:'#e69138',
	        time:2
	    });
	}



	</script>

</body>

</html>
